package models;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Formula;

@Entity
@Table(name="sys_dict")
@SuppressWarnings("serial")
public class Dict extends IdEntity{
	
	
	
	@Formula("(select COUNT(*) from sys_dict d where d.parent_id=0 or d.parent_id is NULL)")
    private int isRoot;
	
	@Formula("(select COUNT(*) from sys_dict d where d.parent_id = id)")
    private int subDictCount;
	
	
	private String name;
	private String code;
	private String value;
	
	//譬如：此项目的类别
	private String outCode;
	private Integer position;
	private String disabled;
	@ManyToOne
	private Dict parent;



	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public int getIsRoot() {
		return isRoot;
	}

	public void setIsRoot(int isRoot) {
		this.isRoot = isRoot;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Dict getParent() {
		return parent;
	}

	public void setParent(Dict parent) {
		this.parent = parent;
	}

	public Integer getPosition() {
		return position;
	}

	public void setPosition(Integer position) {
		this.position = position;
	}

	public int getSubDictCount() {
		return subDictCount;
	}

	public void setSubDictCount(int subDictCount) {
		this.subDictCount = subDictCount;
	}

	public String getDisabled() {
		return disabled;
	}

	public void setDisabled(String disabled) {
		this.disabled = disabled;
	}

	public String toString(){
		return name;
	}

	public String getOutCode() {
		return outCode;
	}

	public void setOutCode(String outCode) {
		this.outCode = outCode;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}
}
